package com.example.administrator.zyfypt_211dsh.fragment;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import com.example.administrator.zyfypt_211dsh.R;
import com.example.administrator.zyfypt_211dsh.activity.MainActivity;
import com.example.administrator.zyfypt_211dsh.bean.SessionID;
import com.example.administrator.zyfypt_211dsh.activity.*;


/**
 * Created by Neusoft on 2017/4/9.
 */

public class Fragment6 extends Fragment {
    private TextView tvinfo;
    private View view=null;
    private Context context;
    private Button btn_quit,btn_focus,btn_collect;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        context=getActivity();
       //动态加载Fragment6的布局文件
        view=inflater.inflate(R.layout.fragment6,container,false);
        //获取布局上的控件，注意通过view获取
        tvinfo=(TextView)view.findViewById(R.id.textView8);
        tvinfo.setText("欢迎您的到来"+ SessionID.username);

        //注意Toast第一个参数上下文
        //Toast.makeText(context, "加载我", Toast.LENGTH_SHORT).show();
        //返回动态生成的view
        return view;
    }
    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        Button button = (Button) getActivity().findViewById(R.id.btn_quit);

        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MainActivity activity = (MainActivity) getActivity();
                activity.finish();
            }
        });

        btn_collect = (Button) view.findViewById(R.id.btn_collect);
        btn_collect.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getActivity(),activity_collection.class);
                startActivity(intent);
            }
        });


        btn_focus = (Button) view.findViewById(R.id.btn_focus);
        btn_focus.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(getActivity(),activity_attention.class);
                startActivity(intent);
            }
        });

    }

}
